<?php

namespace Wgx\Admin\Com\Crud\EditPageInput;

use Wgx\Admin\Com\Crud\EditPageInputBase;

abstract class InputInputBase extends EditPageInputBase
{
    /** @var bool */
    private $isRequired;
    /** @var null|string */
    private $placeholder;
    /** @var null|string */
    private $className;
    /** @var null|string */
    private $specParam;

    /**
     * InputInputBase constructor.
     * @param mixed $origValue - 原值
     * @param bool $isRequired
     * @param null|string $placeholder
     * @param null|string $className - 额外指定的 class
     * @param null|string $specParam - 额外指定的参数
     */
    public function __construct($origValue, $isRequired = false, $placeholder = null, $className = null, $specParam = null)
    {
        $this->origValue = $origValue;
        $this->isRequired = $isRequired;
        $this->placeholder = $placeholder;
        $this->className = $className;
        $this->specParam = $specParam;
    }

    /**
     * 指定 <input> 标签的 type attribute 的值
     * @return string
     */
    abstract public function getType();

    /**
     * @inheritDoc
     */
    public function getIsRequired()
    {
        return $this->isRequired;
    }

    /**
     * @param bool $isRequired
     * @return InputInputBase
     */
    public function setIsRequired($isRequired)
    {
        $this->isRequired = $isRequired;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getPlaceholder()
    {
        return $this->placeholder;
    }

    /**
     * @param string|null $placeholder
     * @return InputInputBase
     */
    public function setPlaceholder($placeholder)
    {
        $this->placeholder = $placeholder;
        return $this;
    }

    /**
     * 额外指定的 class
     * @return string|null
     */
    public function getClassName()
    {
        return $this->className;
    }

    /**
     * @param string|null $className - 额外指定的 class
     * @return InputInputBase
     */
    public function setClassName($className)
    {
        $this->className = $className;
        return $this;
    }

    /**
     * 额外指定的参数
     * @return string|null
     */
    public function getSpecParam()
    {
        return $this->specParam;
    }

    /**
     * @param string|null $specParam - 额外指定的参数
     * @return InputInputBase
     */
    public function setSpecParam($specParam)
    {
        $this->specParam = $specParam;
        return $this;
    }

}